{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
<input type="hidden" name='uid' id='uid' value="{$info.uid}" />
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group">
						<label class="col-sm-2 control-label">昵称：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="nickname" value="{$info.nickname}" name="nickname" class="form-control" placeholder="请输入昵称">
						</div>
					</div>
				<!--	<div class="form-group">
						<label class="col-sm-2 control-label">头像：</label>
						<div class="col-sm-6">
                            <td><a href="javascript:void(0)"  onclick="openImg('{$info.avatar}')"><img height="75" src="{$info.avatar}"></a></td>
						</div>
						<div class="col-sm-2" style="position:relative; right:30px;">
							<span id="avatar_upload"></span>
						</div>
					</div>-->
					<!--lwx 修改头像-->
					<div class="form-group">
						<label class="col-sm-2 control-label">图片：</label>
						<div class="col-sm-6">
							<input type="text" autocomplete="off" id="avatar" value="{$info.avatar}" {if condition="config('my.img_show_status') eq true"}onmousemove="showBigPic(this.value)" onmouseout="closeimg()"{/if} name="image" class="form-control" placeholder="请输入图片">
							<span class="help-block m-b-none image_process"></span>
						</div>
						<div class="col-sm-2" style="position:relative; right:30px;">
							<span id="image_upload"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">余额：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="balance" value="{$info.balance}" name="balance" class="form-control" placeholder="请输入余额">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">真实姓名：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="real_name" value="{$info.real_name}" name="real_name" class="form-control" placeholder="请输入真实姓名">
						</div>
					</div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">身份证号：</label>
                        <div class="col-sm-9">
                            <input type="text" autocomplete="off" id="id_card" value="{$info.id_card}" name="id_card" class="form-control" placeholder="请输入身份证号">
                        </div>
                    </div>
					<div class="form-group">
						<label class="col-sm-2 control-label">手机号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="phone" value="{$info.phone}" name="phone" class="form-control" placeholder="请输入手机号">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">密码：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="pwd" value="{$info.pwd}" name="phone" class="form-control" placeholder="请输入密码">
						</div>
					</div>


					<div class="form-group layui-form" style="display: none">
						<label class="col-sm-2 control-label">年龄：</label>
						<div class="col-sm-9">
							<div class="layui-input-inline" style="width: 160px;">
								<select id="age" name="age" class="province-selector">
									<option value="">选择年龄</option>
									{for start="20" end="81" }
									<option value="{$i}"  {if condition="$info.age eq $i"}selected{/if}>{$i}岁</option>
									{/for}
								</select>
							</div>
						</div>
					</div>

					<div class="form-group" style="display: none">
						<label class="col-sm-2 control-label">身高：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="height" value="{$info.height}" name="height" class="form-control" placeholder="请输入身高">
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">置顶卡：</label>
						<div class="col-sm-9">
							<input hidden="hidden" name="top_card_id" id="top_card_id" value="{$info.top_card_id}"/>
							<input name="top_card_name" readonly class="form-control" id="top_card_name"
								   value="{$info.top_card_name}"/>
							<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.chooseTop()">
								选择
							</button>
						</div>
					</div>

					<div class="form-group" style="display: none">
						<label class="col-sm-2 control-label">生活照：</label>
						<div class="col-sm-6">
							<div class="images pic_list">
								<li id="images_upload"></li>
							</div>
							<div style="clear:both"></div>
							<span class="help-block m-b-none images_process"></span>
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">标签(英文逗号,隔开)：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="tags"  value="{$info.tags}" name="tags" class="form-control" placeholder="请输入标签用英文逗号,隔开">
						</div>
					</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">真实认证标签(英文逗号,隔开)：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="certify_tags" value="{$info.certify_tags}" name="certify_tags" class="form-control" placeholder="请输入真实认证标签用英文逗号,隔开">
						</div>
					</div>


					<div class="form-group">
						<label class="col-sm-2 control-label">推荐标签：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="recommend_tags" value="{$info.recommend_tags}" name="recommend_tags" class="form-control" placeholder="请输入推荐标签用英文逗号,隔开">
						</div>
					</div>


					<!--lwx 是否认证-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否认证：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_auth'])){ $info['is_auth'] = 0; }; ?>
							<input id="is_auth" name="is_auth" value="1" type="radio" {if condition="$info.is_auth eq '1'"}checked{/if} title="是">
							<input id="is_auth" name="is_auth" value="0" type="radio" {if condition="$info.is_auth eq '0'"}checked{/if} title="否">
						</div>
					</div>


					<!--lwx 是否红娘-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否红娘：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_matchmaker'])){ $info['is_matchmaker'] = 0; }; ?>
							<input id="is_matchmaker" name="is_matchmaker" value="1" type="radio" {if condition="$info.is_matchmaker eq '1'"}checked{/if} title="是">
							<input id="is_matchmaker" name="is_matchmaker" value="0" type="radio" {if condition="$info.is_matchmaker eq '0'"}checked{/if} title="否">
						</div>
					</div>

					<!--lwx 是否家长-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否家长：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_parent'])){ $info['is_parent'] = 0; }; ?>
							<input id="is_parent" name="is_parent" value="1" type="radio" {if condition="$info.is_parent eq '1'"}checked{/if} title="是">
							<input id="is_parent" name="is_parent" value="0" type="radio" {if condition="$info.is_parent eq '0'"}checked{/if} title="否">
						</div>
					</div>

					<!--是否会员-->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否会员：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_vip'])){ $info['is_vip'] = 0; }; ?>
							<input id="is_vip" name="is_vip" value="1" type="radio" {if condition="$info.is_vip eq '1'"}checked{/if} title="是">
							<input id="is_vip" name="is_vip" value="0" type="radio" {if condition="$info.is_vip eq '0'"}checked{/if} title="否">
						</div>
					</div>



					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">状态：</label>
						<div class="col-sm-9">
							<input name="status" value="1" type="radio" {if condition="$info.status eq '1'"}checked{/if} title="正常">
							<input name="status" value="0" type="radio" {if condition="$info.status eq '0'"}checked{/if} title="拉黑">
						</div>
					</div>

					</div>

				<div class="form-group">
					<label class="col-sm-2 control-label">会员过期时间：</label>
					<div class="col-sm-9">
						<input type="text" autocomplete="off" value="{if condition="$info.expires_time neq ''"}{$info.expires_time|date='Y-m-d H:i:s'}{/if}" name="expires_time"  placeholder="请输入创建时间" class="form-control" id="expires_time">
					</div>
				</div>

					<!--<div class="form-group">-->
						<!--<label class="col-sm-2 control-label">父级id：</label>-->
						<!--<div class="col-sm-9">-->
							<!--<input type="text" autocomplete="off" id="p_id" value="{$info.p_id}" name="p_id" class="form-control" placeholder="请输入父级id">-->
						<!--</div>-->
					<!--</div>-->
					<!--<div class="form-group">-->
						<!--<label class="col-sm-2 control-label">邀请二维码：</label>-->
						<!--<div class="col-sm-9">-->
							<!--<input type="text" autocomplete="off" id="qr_code" value="{$info.qr_code}" name="qr_code" class="form-control" placeholder="请输入邀请二维码">-->
						<!--</div>-->
					<!--</div>-->

				<div class="form-group">
					<label class="col-sm-2 control-label">上级红娘ID：</label>
					<div class="col-sm-9">
						<input hidden="text" value="{$info.matchmaker_id}" name="matchmaker_id" id="matchmaker_id"  />
						<input   value="{$info.top_member_name}" readonly class="form-control" id="top_member_name"/>
						<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.chooseMemberTop()">
							选择
						</button>
					</div>
				</div>
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">是否是管理员：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['is_admin'])){ $info['is_admin'] = 0; }; ?>
							<input name="is_admin" value="1" type="radio" {if condition="$info.is_admin eq '1'"}checked{/if} title="是">
							<input name="is_admin" value="0" type="radio" {if condition="$info.is_admin eq '0'"}checked{/if} title="否">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">红心余额：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="virtual_currency_balance" value="{$info.virtual_currency_balance}" name="virtual_currency_balance" class="form-control" placeholder="请输入红心余额">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">会员卡号：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="vip_number" value="{$info.vip_number}" name="vip_number" class="form-control" placeholder="请输入会员卡号">
						</div>
					</div>

					<div class="form-group" style="display: none">
						<label class="col-sm-2 control-label">简介：</label>
						<div class="col-sm-9">
								<textarea id="s_desc" name="s_desc" class="form-control"
										  placeholder="请输入简介">{$info.s_desc}</textarea>
						</div>
					</div>


                    <div class="form-group layui-form">
                        <label class="col-sm-2 control-label">审核状态：</label>
                        <div class="col-sm-9">
                            <input name="auth_status" value="1" type="radio" {if condition="$info.auth_status eq '1'"}checked{/if} title="待审核">
                            <input name="auth_status" value="2" type="radio" {if condition="$info.auth_status eq '2'"}checked{/if} title="通过">
                            <input name="auth_status" value="3" type="radio" {if condition="$info.auth_status eq '3'"}checked{/if} title="拒绝">
                        </div>
                    </div>

					<!--<div class="form-group layui-form">-->
						<!--<label class="col-sm-2 control-label">性别：</label>-->
						<!--<div class="col-sm-9">-->
							<!--<?php if(!isset($info['sex'])){ $info['sex'] = 1; }; ?>-->
							<!--<input name="sex" value="1" type="radio" {if condition="$info.sex eq '1'"}checked{/if} title="男">-->
							<!--<input name="sex" value="0" type="radio" {if condition="$info.sex eq '0'"}checked{/if} title="女">-->
						<!--</div>-->
					<!--</div>-->
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.update()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
//uploader('avatar_upload','avatar','image',false,'','{:getUploadServerUrl()}');
uploader('image_upload','avatar','image',false,'','{:getUploadServerUrl()}');

uploader('images_upload', 'images', 'image', true, '{$info.pictures}', '{:getUploadServerUrl()}');
setUploadButton('images_upload');


laydate.render({elem: '#expires_time',type: 'datetime',trigger:'click'});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('uid').set('nickname').set('avatar').set('balance').set('real_name').set('phone').set('is_auth')
			.set('create_time').set('is_vip').set('expires_time').set('p_id').set('qr_code').set('pwd')
			.set('virtual_currency_balance').set('vip_number').set('auth_status').set('s_desc').set('top_card_id')
			.set('top_card_name').set('tags').set('age').set('height').set('certify_tags').set('recommend_tags').set('matchmaker_id');
};

CodeInfoDlg.chooseTop = function () {
	var index = layer.open({
		type: 2,
		title: '置顶卡',
		area: ['800px', '100%'],
		fix: false,
		maxmin: true,
		content: Feng.ctxPath + '/ZhTopCard/selectList'
	});
	if (!IsPC()) {
		layer.full(index)
	}
}

function GetTopValue(value) {
	$('#top_card_name').val(value.name)
	$('#top_card_id').val(value.id)
	console.log('获取上级推荐人', value)
}

//选择用户账号
CodeInfoDlg.chooseMemberTop = function () {
	var index = layer.open({
		type: 2,
		title: '选择用户账号',
		area: ['800px', '100%'],
		fix: false,
		maxmin: true,
		content: Feng.ctxPath + '/member/selectList'
	});
	if (!IsPC()) {
		layer.full(index)
	}
}

// 获取关联的用户
function GetMemberTopValue(value) {
	let name = "";
	if(value.name != null){
		name = value.name;
	}
	name += " "+ value.phone;
	$('#top_member_name').val(name)
	$('#matchmaker_id').val(value.matchmaker_id)
}


CodeInfoDlg.update = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }

	var images = [];
	$(".images li").each(function () {
		if ($(this).find('img').attr('src')) {
			images.push($(this).find('img').attr('src'));
		}
	});

	var is_matchmaker = $("input[name = 'is_matchmaker']:checked").val();
	var status = $("input[name = 'status']:checked").val();
	var is_admin = $("input[name = 'is_admin']:checked").val();
	var sex = $("input[name = 'sex']:checked").val();
	var avatar=$("input[name = 'avatar']").val();
    var auth_status = $("input[name = 'auth_status']:checked").val();
	var ajax = new $ax(Feng.ctxPath + "/Member/update", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	ajax.set('is_matchmaker',is_matchmaker);
	 ajax.set('status',status);
	 ajax.set('is_admin',is_admin);
	 ajax.set('pictures', JSON.stringify(images));
	 ajax.set('sex',sex);
	 ajax.set('avatar',avatar);
	 ajax.set(this.CodeInfoData);
	 ajax.set('auth_status',auth_status);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
